#include <cstdio>
#include <algorithm>
using namespace std;
const int maxn=100010;
struct Person
{
    int ID_Number,Virtue_Grade,Talent_Grade,level;
} humans[maxn],human;
bool cmp(Person p1,Person p2)
{
    if (p1.level==p2.level)
    {
        if ((p1.Virtue_Grade+p1.Talent_Grade)==(p2.Virtue_Grade+p2.Talent_Grade))
        {
            if(p1.Virtue_Grade==p2.Virtue_Grade)
            {
                return p1.ID_Number<p2.ID_Number;
            }
            else
            {
                return p1.Virtue_Grade>p2.Virtue_Grade;
            }
        }
        else
        {
            return (p1.Virtue_Grade+p1.Talent_Grade)>(p2.Virtue_Grade+p2.Talent_Grade);
        }
    }
    else
    {
        return p1.level>p2.level;
    }
}
int main_1062()
{
    int N,L,H,M=0;
    scanf("%d%d%d",&N,&L,&H);
    for (int i=0; i<N ; ++i )
    {
        scanf("%d%d%d",&human.ID_Number,&human.Virtue_Grade,&human.Talent_Grade);
        if (human.Virtue_Grade>=L&&human.Talent_Grade>=L)
        {
            human.level=0;//the rest
            if (human.Virtue_Grade>=H&&human.Talent_Grade>=H)
            {
                human.level=3;//sages
            }
            else if(human.Talent_Grade<H&&human.Virtue_Grade>=H)
            {
                human.level=2;//noblemen
            }
            else if(human.Virtue_Grade<H&&human.Talent_Grade<H&&human.Virtue_Grade>=human.Talent_Grade)
            {
                human.level=1;//fool men
            }
            humans[M++]=human;
        }
    }
    sort(humans,humans+M,cmp);
    printf("%d\n",M);
    for (int i=0; i<M ; ++i )
    {
        printf("%d %d %d\n",humans[i].ID_Number,humans[i].Virtue_Grade,humans[i].Talent_Grade);
    }
    return 0;
}
